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

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

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

n = A("n")
b = B("b")
g = C("g")
l = B("l")

n.x = g
n.p = l
b.u = g
b.x = g
b.y = g
g.v = b
l.u = g
l.x = g
l.y = g
assert l.y.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.p: B = None
        self.txt = txt

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

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

n = A("n")
b = B("b")
g = C("g")
l = B("l")

n.x = g
n.p = l
b.u = g
b.x = g
b.y = g
g.v = b
l.u = g
l.x = g
l.y = g
assert l.y.v.u.v.txt == "b"