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

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: F = None
        self.s: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: E = None
        self.o: A = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.x: B = None
        self.z: F = None
        self.s: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: E = None
        self.o: A = None
        self.t: F = None
        self.v: B = None
        self.txt = txt

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

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

g.o = l
g.x = k
d.t = g
d.q = l
d.o = k
k.y = b
l.x = d
l.z = b
l.s = b
h.q = e
h.o = g
h.t = b
h.v = d
b.s = k
b.u = k
b.r = l
b.o = l
b.p = g
e.q = h
e.o = g
e.t = b
e.v = d
assert l.s.u.y.p.txt == "g"