class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.o: D = None
        self.s: B = None
        self.x: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: B = None
        self.x: D = None
        self.y: D = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: A = None
        self.v: A = None
        self.y: A = None
        self.p: F = None
        self.q: A = None
        self.txt = txt

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

b.p = h
b.u = e
h.u = n
h.t = n
h.s = n
h.o = e
h.x = e
f.z = b
f.x = e
e.z = m
e.p = f
m.q = i
m.v = h
m.x = e
m.y = e
m.t = f
d.r = n
d.u = b
d.v = b
d.y = b
d.q = b
d.p = i
n.u = h
n.t = h
n.s = h
n.o = e
n.x = e
i.r = n
i.u = b
i.v = b
i.y = b
i.q = b
i.p = d
assert d.r.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: B = None
        self.t: B = None
        self.o: D = None
        self.s: B = None
        self.x: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: E = None
        self.p: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: F = None
        self.v: B = None
        self.x: D = None
        self.y: D = None
        self.t: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: A = None
        self.v: A = None
        self.y: A = None
        self.p: F = None
        self.q: A = None
        self.txt = txt

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

b.p = h
b.u = e
h.u = n
h.t = n
h.s = n
h.o = e
h.x = e
f.z = b
f.x = e
e.z = m
e.p = f
m.q = i
m.v = h
m.x = e
m.y = e
m.t = f
d.r = n
d.u = b
d.v = b
d.y = b
d.q = b
d.p = i
n.u = h
n.t = h
n.s = h
n.o = e
n.x = e
i.r = n
i.u = b
i.v = b
i.y = b
i.q = b
i.p = d
assert d.r.x.p.txt == "f"