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

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

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

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

g = A("g")
f = B("f")
j = C("j")
k = D("k")
b = C("b")

g.y = j
g.t = f
f.v = g
f.r = g
f.q = k
j.u = b
j.o = b
j.v = f
k.q = g
k.p = g
k.u = g
b.u = j
b.o = j
b.v = f
assert f.v.y.u.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.t: B = None
        self.txt = txt

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

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

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

g = A("g")
f = B("f")
j = C("j")
k = D("k")
b = C("b")

g.y = j
g.t = f
f.v = g
f.r = g
f.q = k
j.u = b
j.o = b
j.v = f
k.q = g
k.p = g
k.u = g
b.u = j
b.o = j
b.v = f
assert f.v.y.u.u.v.txt == "f"