class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: C = None
        self.s: D = None
        self.o: B = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
g = C("g")
b = D("b")
a = C("a")

f.r = b
f.s = b
f.y = g
f.o = d
d.t = b
g.r = d
g.x = d
b.t = a
b.o = a
b.x = f
b.v = f
a.r = d
a.x = d
assert b.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: C = None
        self.s: D = None
        self.o: B = None
        self.txt = txt

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

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

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

f = A("f")
d = B("d")
g = C("g")
b = D("b")
a = C("a")

f.r = b
f.s = b
f.y = g
f.o = d
d.t = b
g.r = d
g.x = d
b.t = a
b.o = a
b.x = f
b.v = f
a.r = d
a.x = d
assert b.t.x.t.txt == "b"