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

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

b = A("b")
e = B("e")
i = B("i")
g = B("g")
c = A("c")
d = B("d")
n = B("n")
a = A("a")

b.x = d
b.t = d
e.o = d
e.r = b
i.o = n
i.r = c
g.o = d
g.r = a
c.x = g
c.t = i
d.o = n
d.r = a
n.o = g
n.r = c
a.x = n
a.t = i
assert d.o.r.t.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.t: B = None
        self.txt = txt

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

b = A("b")
e = B("e")
i = B("i")
g = B("g")
c = A("c")
d = B("d")
n = B("n")
a = A("a")

b.x = d
b.t = d
e.o = d
e.r = b
i.o = n
i.r = c
g.o = d
g.r = a
c.x = g
c.t = i
d.o = n
d.r = a
n.o = g
n.r = c
a.x = n
a.t = i
assert d.o.r.t.r.x.txt == "g"