class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.o: A = None
        self.s: B = None
        self.txt = txt

f = A("f")
c = B("c")
j = C("j")
m = D("m")
i = E("i")
h = C("h")
l = E("l")
n = A("n")

f.p = h
f.y = c
f.q = i
c.t = i
j.x = c
j.z = c
j.u = h
m.q = h
i.r = c
i.s = c
i.x = j
i.o = f
h.x = c
h.z = c
h.u = j
l.r = c
l.s = c
l.x = j
l.o = f
n.p = h
n.y = c
n.q = i
assert j.z.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: B = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.r: B = None
        self.x: C = None
        self.o: A = None
        self.s: B = None
        self.txt = txt

f = A("f")
c = B("c")
j = C("j")
m = D("m")
i = E("i")
h = C("h")
l = E("l")
n = A("n")

f.p = h
f.y = c
f.q = i
c.t = i
j.x = c
j.z = c
j.u = h
m.q = h
i.r = c
i.s = c
i.x = j
i.o = f
h.x = c
h.z = c
h.u = j
l.r = c
l.s = c
l.x = j
l.o = f
n.p = h
n.y = c
n.q = i
assert j.z.t.x.txt == "j"