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

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

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

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

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

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

a = A("a")
b = B("b")
c = C("c")
j = D("j")
h = E("h")
n = F("n")
e = C("e")
g = B("g")
l = B("l")

a.q = b
b.t = c
b.r = l
c.o = j
c.x = n
c.t = n
c.p = e
c.q = h
j.q = b
j.v = a
h.p = a
h.t = c
h.z = j
h.s = n
n.u = j
e.o = j
e.x = n
e.t = n
e.p = c
e.q = h
g.t = c
g.r = l
l.t = c
l.r = b
assert h.s.u.q.t.x.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

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

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

a = A("a")
b = B("b")
c = C("c")
j = D("j")
h = E("h")
n = F("n")
e = C("e")
g = B("g")
l = B("l")

a.q = b
b.t = c
b.r = l
c.o = j
c.x = n
c.t = n
c.p = e
c.q = h
j.q = b
j.v = a
h.p = a
h.t = c
h.z = j
h.s = n
n.u = j
e.o = j
e.x = n
e.t = n
e.p = c
e.q = h
g.t = c
g.r = l
l.t = c
l.r = b
assert h.s.u.q.t.x.u.q.txt == "b"