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

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

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

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

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

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

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

a.u = j
j.z = c
j.y = c
n.y = j
n.x = b
b.v = f
b.x = f
b.y = f
b.q = a
b.o = a
b.u = g
c.y = f
f.o = n
f.u = a
f.r = j
g.y = f
assert a.u.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

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

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

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

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

a.u = j
j.z = c
j.y = c
n.y = j
n.x = b
b.v = f
b.x = f
b.y = f
b.q = a
b.o = a
b.u = g
c.y = f
f.o = n
f.u = a
f.r = j
g.y = f
assert a.u.z.y.txt == "f"