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

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: A = None
        self.r: B = None
        self.x: E = None
        self.txt = txt

h = A("h")
c = B("c")
l = C("l")
d = D("d")
e = E("e")
k = F("k")
b = A("b")

h.y = d
h.x = d
h.q = l
c.p = k
l.y = e
l.x = e
l.u = d
l.t = d
d.u = c
d.y = b
d.q = k
e.q = l
k.o = d
k.u = h
k.r = c
k.x = e
b.y = d
b.x = d
b.q = l
assert d.u.p.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: C = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: F = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: D = None
        self.u: A = None
        self.r: B = None
        self.x: E = None
        self.txt = txt

h = A("h")
c = B("c")
l = C("l")
d = D("d")
e = E("e")
k = F("k")
b = A("b")

h.y = d
h.x = d
h.q = l
c.p = k
l.y = e
l.x = e
l.u = d
l.t = d
d.u = c
d.y = b
d.q = k
e.q = l
k.o = d
k.u = h
k.r = c
k.x = e
b.y = d
b.x = d
b.q = l
assert d.u.p.u.q.txt == "l"