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

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: F = None
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
d = C("d")
k = D("k")
f = E("f")
i = F("i")
m = A("m")
a = B("a")

b.u = i
c.x = d
c.q = d
c.z = m
c.o = i
c.v = i
d.p = a
k.r = f
k.w = i
k.t = c
k.v = c
f.t = i
f.p = a
i.x = d
m.u = i
a.x = d
a.q = d
a.z = b
a.o = i
a.v = i
assert f.p.v.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: F = None
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

b = A("b")
c = B("c")
d = C("d")
k = D("k")
f = E("f")
i = F("i")
m = A("m")
a = B("a")

b.u = i
c.x = d
c.q = d
c.z = m
c.o = i
c.v = i
d.p = a
k.r = f
k.w = i
k.t = c
k.v = c
f.t = i
f.p = a
i.x = d
m.u = i
a.x = d
a.q = d
a.z = b
a.o = i
a.v = i
assert f.p.v.x.p.txt == "a"