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

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

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

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

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

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

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

f.x = a
f.y = e
a.o = c
a.x = d
d.q = c
h.p = k
h.u = d
e.y = h
e.v = a
e.p = d
c.p = g
c.t = e
b.x = a
b.y = e
k.p = g
k.t = e
g.p = k
g.t = e
assert a.x.q.t.y.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: E = None
        self.txt = txt

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

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

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

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

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

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

f.x = a
f.y = e
a.o = c
a.x = d
d.q = c
h.p = k
h.u = d
e.y = h
e.v = a
e.p = d
c.p = g
c.t = e
b.x = a
b.y = e
k.p = g
k.t = e
g.p = k
g.t = e
assert a.x.q.t.y.p.t.txt == "e"