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

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

c = A("c")
j = B("j")
g = A("g")
e = B("e")

c.o = j
c.v = j
j.u = c
g.o = e
g.v = e
e.u = g
assert j.u.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.v: B = None
        self.txt = txt

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

c = A("c")
j = B("j")
g = A("g")
e = B("e")

c.o = j
c.v = j
j.u = c
g.o = e
g.v = e
e.u = g
assert j.u.v.u.v.txt == "j"