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

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: D = None
        self.txt = txt

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

d = A("d")
f = B("f")
g = C("g")
n = D("n")

d.u = g
f.t = d
g.s = n
g.v = n
n.t = f
n.x = f
assert g.s.t.t.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.v: D = None
        self.txt = txt

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

d = A("d")
f = B("f")
g = C("g")
n = D("n")

d.u = g
f.t = d
g.s = n
g.v = n
n.t = f
n.x = f
assert g.s.t.t.u.txt == "g"