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

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

b = A("b")
g = B("g")
h = B("h")
i = B("i")
l = A("l")
j = A("j")

b.u = l
b.v = l
g.s = b
g.o = b
h.s = j
h.o = l
i.s = b
i.o = j
l.u = b
l.v = b
j.u = b
j.v = b
assert g.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.v: A = None
        self.txt = txt

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

b = A("b")
g = B("g")
h = B("h")
i = B("i")
l = A("l")
j = A("j")

b.u = l
b.v = l
g.s = b
g.o = b
h.s = j
h.o = l
i.s = b
i.o = j
l.u = b
l.v = b
j.u = b
j.v = b
assert g.o.u.u.txt == "b"