class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.v: B = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: C = None
        self.u: F = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: D = None
        self.txt = txt

a = A("a")
h = B("h")
b = C("b")
n = D("n")
d = E("d")
i = F("i")
c = F("c")
f = A("f")

a.r = h
a.v = h
a.y = h
a.x = n
h.v = a
b.x = h
n.v = a
d.s = b
d.w = b
d.u = c
d.p = h
i.u = b
i.y = n
c.u = b
c.y = n
f.r = h
f.v = h
f.y = h
f.x = n
assert i.u.x.v.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: D = None
        self.v: B = None
        self.y: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.s: C = None
        self.w: C = None
        self.u: F = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: D = None
        self.txt = txt

a = A("a")
h = B("h")
b = C("b")
n = D("n")
d = E("d")
i = F("i")
c = F("c")
f = A("f")

a.r = h
a.v = h
a.y = h
a.x = n
h.v = a
b.x = h
n.v = a
d.s = b
d.w = b
d.u = c
d.p = h
i.u = b
i.y = n
c.u = b
c.y = n
f.r = h
f.v = h
f.y = h
f.x = n
assert i.u.x.v.x.v.txt == "a"