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

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

g = A("g")
c = B("c")
h = A("h")
b = B("b")

g.t = c
g.y = c
c.x = b
h.t = c
h.y = c
b.x = c
assert g.y.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: B = None
        self.txt = txt

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

g = A("g")
c = B("c")
h = A("h")
b = B("b")

g.t = c
g.y = c
c.x = b
h.t = c
h.y = c
b.x = c
assert g.y.x.x.txt == "c"